<template>
    <a-card :bordered="false">
        <LTable
                ref="empSingleSelectList"
                size="middle"
                rowKey="keyId"
                :formAttributes="formAttributes"
                :columns="columns"
                axiosUrl="/SysEmpController/page"
                :showPagination="true"
                :showQueryForm="true"
                :customRow="customRow"
                :rowClassName="tableRowClass"
             >
            </LTable>
    </a-card>
    
</template>

<script>
import LTable from '@/components/lt/LTable'
import {SysMixin} from '@/mixins/SysMixin'
import {filterDictText} from '@/utils/util'
import defaultSettings from '@/config/defaultSettings'

export default {
    name:'empSingleSelect',
    components:{LTable},
    mixins:[SysMixin],
    data(){
        return{
            defaultSettings,
            title:'详情',
            visible:false,
            confirmLoading: false,
            selectedRecord:{},
            formAttributes:[
                {field:'orgNo',label:'单位',component:'treeSelect',dictCode:defaultSettings.数据字典.组织下拉树,condition:'eq'},
                {field:'empName',label:'人员姓名',component:'input',condition:'like'},
                {field:'accountNo',label:'账号',component:'input',condition:'like'},
                {field:'empNo',label:'工号',component:'input',condition:'like'},
            ],
         
            columns:[
                {
                    title: '序号',
                    dataIndex: '',
                    key:'rowIndex',
                    width:60,
                    align:"center",
                    customRender:function (t,r,index) {
                      return parseInt(index)+1;
                    }
                },
                 {
                    title: '单位',
                    dataIndex: 'orgNo',
                    customRender:(text)=>{
                        if(!text){
                            return ''
                        }else{
                            return this.dictText(defaultSettings.数据字典.组织下拉树,text)
                            // return filterDictText(this.$refs.empSingleSelectList.dictInfo["4kKW3-4qqq"],{},text+"")
                        }
                    }
                },
                
                {
                    title: '人员编号',
                    dataIndex: 'empNo'
                },
                {
                    title: '人员姓名',
                    dataIndex: 'empName'
                    
                },
                {
                    title: '登陆账号',
                    dataIndex: 'accountNo'
                    
                },
                {
                    title: '状态',
                    dataIndex: 'isUse',
                    scopedSlots: { customRender: 'isUse' }
                },
               
            ],
            initDictCodes:defaultSettings.数据字典.组织下拉树,
        }
    },
    methods:{
        customRow(record){
            return{
                on:{
                    click:(e)=>{
                        this.selectedRecord = record
                    }
                }
            }
        },
        tableRowClass(record,index){
            if (this.selectedRecord && this.selectedRecord.empNo==record.empNo){
                return "selectRowClass"
            }else{
                return ""
            }
            
        },
        getSelectedRecord(){
            return this.selectedRecord
        }
    }
}
</script>

<style lang="less" >
    @import "../../../layouts/BasicLayout.less";
    .selectRowClass{
        background-color:var(--primary-color) !important;
        
    }
</style>